﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SoundServant.Controls;

namespace SoundServant
{
    /// <summary>
    /// Interaction logic for AddCD.xaml
    /// </summary>
    public partial class ChangeTypeWindow : SSWindow
    {
        MeetingType type;

        public ChangeTypeWindow(MeetingType _type)
        {
            InitializeComponent();
            type = _type;
            foreach (Object index in Enum.GetValues(typeof(MeetingType)))
            {
                MeetingTypeListBoxItem meetingType = new MeetingTypeListBoxItem();
                meetingType.Content = SS.FullMeetingType((MeetingType)index);
                meetingType.MeetingType = (MeetingType)index;
                if (type == (MeetingType)index) meetingType.IsSelected = true;
                TypeComboBox.Items.Add(meetingType);
            }
            TypeComboBox.SelectionChanged += new SelectionChangedEventHandler(TypeComboBox_SelectionChanged);
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        public MeetingType ChangeTypeDialog()
        {
            ShowDialog();
            return type;
        }

        private void TypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            type = ((MeetingTypeListBoxItem)e.AddedItems[0]).MeetingType;
            Close();
        }
    }
    class MeetingTypeListBoxItem : ListBoxItem
    {
        public MeetingType MeetingType;

        public MeetingTypeListBoxItem()
            : base()
        {
            FontSize = 14D;
            Padding = new Thickness(6);
            Margin = new Thickness(6);
        }
    }
}
